﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OAPlatform.DomainModel.Contract;
using OAPlatform.CommonHelper;
using OAPlatform.DomainModel.Model;

namespace OAPlatform.DomainModel.Service
{
    class DepartmentService
    {
        IUserRepository userRepository = null;
        IDepartmentRepository departmentRepository = null;

        public DepartmentService(IUserRepository userRepository, IDepartmentRepository departmentRepository)
        {
            Check.Argument.IsNotNull(userRepository, "userRepository");
            Check.Argument.IsNotNull(departmentRepository, "departmentRepository");
        }

        public void AddDepartment(User user, string departmentName, Department parentDepartment)
        {
            if (user.Authenticate("AddDepartment"))
            {
                Department department = new Department { Name = departmentName, Parent = parentDepartment ?? user.Band.Department };
                departmentRepository.Add(department);
            }
        }


    }
}
